package com.kingdee.eas.scm.im.inv.app;

import java.util.ArrayList;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.IObjectValue;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.eas.base.botp.util.BotRelationUtil;
import com.kingdee.eas.basedata.org.StorageOrgUnitFactory;
import com.kingdee.eas.basedata.org.StorageOrgUnitInfo;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.scm.im.inv.MatAssembleBillInfo;
import com.kingdee.eas.scm.im.inv.MatDisassembleBillInfo;
import com.kingdee.eas.scm.im.inv.OtherInWarehsBillFactory;
import com.kingdee.eas.scm.im.inv.OtherInWarehsBillInfo;
import com.kingdee.eas.scm.im.inv.OtherIssueBillFactory;
import com.kingdee.eas.scm.im.inv.OtherIssueBillInfo;
import com.kingdee.eas.scm.im.inv.utils.OtherBillUtil;

public class MatDisassembleBillControllerBeanEx extends
		MatDisassembleBillControllerBean {
	@Override
	protected void _passAudit(Context arg0, IObjectPK arg1, IObjectValue arg2)
			throws EASBizException, BOSException {
		super._passAudit(arg0, arg1, arg2);
		
		MatDisassembleBillInfo matDisassembleBillInfo = (MatDisassembleBillInfo)arg2;
		StorageOrgUnitInfo storageOrgUnit = matDisassembleBillInfo.getStorageOrgUnit();
		storageOrgUnit = StorageOrgUnitFactory.getLocalInstance(arg0).getStorageOrgUnitInfo(new ObjectUuidPK(storageOrgUnit.getId().toString()));
		if(!storageOrgUnit.getNumber().equals("MAC39TW9-7")){
			return ;
		}
		
        ArrayList srcIds = BotRelationUtil.getDestObjectIdByDestType(arg0, matDisassembleBillInfo.getId().toString(), "A4D04D23");
        if(srcIds.size()>0){
	        OtherInWarehsBillInfo billInfo = OtherInWarehsBillFactory.getLocalInstance(arg0).getOtherInWarehsBillInfo(new ObjectUuidPK(srcIds.get(0).toString()));
			OtherBillUtil otherBillUtil = new OtherBillUtil();
			otherBillUtil.otherInWarehsBillPush(arg0, billInfo);
        }
        srcIds = BotRelationUtil.getDestObjectIdByDestType(arg0, matDisassembleBillInfo.getId().toString(), "A4D04D24");
        if(srcIds.size()>0){
        	OtherIssueBillInfo billInfo = OtherIssueBillFactory.getLocalInstance(arg0).getOtherIssueBillInfo(new ObjectUuidPK(srcIds.get(0).toString()));
			OtherBillUtil otherBillUtil = new OtherBillUtil();
			otherBillUtil.otherIssueBillPush(arg0, billInfo);
        }
	}
}
